<?php
/**
 * licenses : MIT
 * creatTime: 2020/5/20
 * author : weblinuxgame
 * filename: UrlDiscoverService.php
 */

namespace App\Services;

use ArrayAccess;
use Tightenco\Collect\Support\Collection;
use Illuminate\Support\Collection as BaseCollection;

/**
 * Class UrlDiscoverService
 * @package App\Services
 */
class UrlDiscoverService extends BaseService
{
    /**
     * @param $item
     * @return bool
     */
    public static function dispatch($item)
    {
        if (empty($item)) {
            return false;
        }
        if (self::isArrayAccess($item)) {
            foreach ($item as $it) {
                self::dispatch($it);
            }
        }
        if (is_string($item)) {
            return self::urlItem($item);
        }
        if (is_array($item)) {
            return self::arrayItem($item);
        }
        return false;
    }

    public static function isArrayAccess($object)
    {
        return $object instanceof Collection || $object instanceof BaseCollection || $object instanceof ArrayAccess;
    }

    protected static function urlItem(string $url): bool
    {

    }

    protected static function arrayItem(array $item): bool
    {

    }

}
